<?php
	$options = get_option('inove_options');

	if($options['feed'] && $options['feed_url']) {
		if (substr(strtoupper($options['feed_url']), 0, 7) == 'HTTP://') {
			$feed = $options['feed_url'];
		} else {
			$feed = 'http://' . $options['feed_url'];
		}
	} else {
		$feed = get_bloginfo('rss2_url');
	}
?>

<!-- sidebar START -->
<div id="sidebar">

<!-- sidebar north START -->
<div id="northsidebar" class="sidebar">

	<!-- feeds -->
	<div class="widget widget_feeds" style="height:130px;border:0px solid blue;">
		<div class="content">
			<div id="subscribe">
				<a id="feedrss" title="<?php _e('Subscribe to this blog...', 'inove'); ?>" href="<?php echo $feed; ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr> feed', 'inove'); ?></a>
				<ul id="feed_readers">
					<li id="google_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('Google', 'inove'); ?>" href="http://fusion.google.com/add?feedurl=<?php echo $feed; ?>"><span><?php _e('Google', 'inove'); ?></span></a></li>
					<li id="youdao_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('Youdao', 'inove'); ?>" href="http://reader.youdao.com/#url=<?php echo $feed; ?>"><span><?php _e('Youdao', 'inove'); ?></span></a></li>
					<li id="xianguo_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('Xian Guo', 'inove'); ?>" href="http://www.xianguo.com/subscribe.php?url=<?php echo $feed; ?>"><span><?php _e('Xian Guo', 'inove'); ?></span></a></li>
					<li id="zhuaxia_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('Zhua Xia', 'inove'); ?>" href="http://www.zhuaxia.com/add_channel.php?url=<?php echo $feed; ?>"><span><?php _e('Zhua Xia', 'inove'); ?></span></a></li>
					<li id="yahoo_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('My Yahoo!', 'inove'); ?>"	href="http://add.my.yahoo.com/rss?url=<?php echo $feed; ?>"><span><?php _e('My Yahoo!', 'inove'); ?></span></a></li>
					<li id="newsgator_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('newsgator', 'inove'); ?>"	href="http://www.newsgator.com/ngs/subscriber/subfext.aspx?url=<?php echo $feed; ?>"><span><?php _e('newsgator', 'inove'); ?></span></a></li>
					<li id="bloglines_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('Bloglines', 'inove'); ?>"	href="http://www.bloglines.com/sub/<?php echo $feed; ?>"><span><?php _e('Bloglines', 'inove'); ?></span></a></li>
					<li id="inezha_reader"><a class="reader" title="<?php _e('Subscribe with ', 'inove'); _e('iNezha', 'inove'); ?>"	href="http://inezha.com/add?url=<?php echo $feed; ?>"><span><?php _e('iNezha', 'inove'); ?></span></a></li>
				</ul>
			</div>
			<?php if($options['feed_email'] && $options['feed_url_email']) : ?>
				<a id="feedemail" title="<?php _e('Subscribe to this blog via email...', 'inove'); ?>" href="<?php echo $options['feed_url_email']; ?>"><?php _e('Email feed', 'inove'); ?></a>
			<?php endif; ?>
			<div class="fixed"></div>
		</div>
		<div class="content" style="border:0px solid blue;font-weight:bold;line-height:30px;font-size:1.2em;">
			手机访问：<a href="http://wap.phpcoding.cn">http://wap.phpcoding.cn</a>
		</div>
		<div id="searchbox" style="text-align:center;margin:5px auto;margin-left:5px;">
<!-- SiteSearch Google -->
<form method="get" action="http://www.google.cn/custom" target="google_window">
<table border="0" bgcolor="#f7f7f7">
<tr><td nowrap="nowrap" valign="top" align="left" height="32">

</td>
<td nowrap="nowrap">
<input type="hidden" name="domains" value="www.phpcoding.cn"></input>
<label for="sbi" style="display: none">输入您的搜索字词</label>
<input type="text" name="q" size="25" maxlength="255" value="" id="sbi"></input>
<label for="sbb" style="display: none">提交搜索表单</label>
<input type="submit" name="sa" value="Google 搜索" id="sbb"></input>
</td></tr>
<tr>
<td>&nbsp;</td>
<td nowrap="nowrap">
<table>
<tr>
<td style='white-space: nowrap;'>
<input type="radio" name="sitesearch" value="" checked id="ss0"></input>
<label for="ss0" title="搜索网络"><font size="-1" color="#000000">Web</font></label></td>
<td style='white-space: nowrap;'>
<input type="radio" name="sitesearch" value="www.phpcoding.cn" id="ss1"></input>
<label for="ss1" title="搜索 www.phpcoding.cn"><font size="-1" color="#000000">www.phpcoding.cn</font></label></td>
</tr>
</table>
<input type="hidden" name="client" value="pub-9812078506892870"></input>
<input type="hidden" name="forid" value="1"></input>
<input type="hidden" name="ie" value="UTF-8"></input>
<input type="hidden" name="oe" value="UTF-8"></input>
<input type="hidden" name="safe" value="active"></input>
<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:161;L:http://www.phpcoding.cn/wp-content/uploads/2009/04/achaoorgl.gif;S:http://;FORID:1"></input>
<input type="hidden" name="hl" value="zh-CN"></input>
</td></tr></table>
</form>
<!-- SiteSearch Google -->
		</div>

	</div>

	<!-- showcase -->
	<?php if( $options['showcase_content'] && (
		($options['showcase_registered'] && $user_ID) || 
		($options['showcase_commentator'] && !$user_ID && isset($_COOKIE['comment_author_'.COOKIEHASH])) || 
		($options['showcase_visitor'] && !$user_ID && !isset($_COOKIE['comment_author_'.COOKIEHASH]))
	) ) : ?>
		<div class="widget">
			<?php if($options['showcase_caption']) : ?>
				<h3><?php if($options['showcase_title']){echo($options['showcase_title']);}else{_e('Showcase', 'inove');} ?></h3>
			<?php endif; ?>
			<div class="content">
				<?php echo($options['showcase_content']); ?>
			</div>
		</div>
	<?php endif; ?>

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('north_sidebar') ) : ?>

	<!-- posts -->
	<?php
		if (is_single()) {
			$posts_widget_title = 'Recent Posts';
		} else {
			$posts_widget_title = 'Random Posts';
		}
	?>

	<div class="widget widget_categories">
		<h3><?php echo $posts_widget_title; ?></h3>
		<ul>
			<?php
				if (is_single()) {
					$posts = get_posts('numberposts=10&orderby=post_date');
				} else {
					$posts = get_posts('numberposts=5&orderby=rand');
				}
				foreach($posts as $post) {
					setup_postdata($post);
					echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
				}
				$post = $posts[0];
			?>
		</ul>
	</div>

	<!-- recent comments -->
	<?php if( function_exists('wp_recentcomments') ) : ?>
		<div class="widget">
			<h3>Recent Comments</h3>
			<ul>
				<?php wp_recentcomments('limit=5&length=16&post=false&smilies=true'); ?>
			</ul>
		</div>
	<?php endif; ?>

	<!-- tag cloud -->
	<?php if (!is_single()) : ?>
		<div id="tag_cloud" class="widget">
			<h3>Tag Cloud</h3>
			<?php wp_tag_cloud('smallest=8&largest=16'); ?>
		</div>
	<?php endif; ?>

<?php endif; ?>
</div>
<!-- sidebar north END -->

<!-- google adsense start -->
<div class="sidebar">
<script type="text/javascript"><!--
google_ad_client = "pub-9812078506892870";
/* 侧栏广告二(300x250, 创建于 09-5-14) */
google_ad_slot = "7485682968";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<!-- google adsense end -->

<?php 
function ask2link_ad_helper($url)
{
  $content = '';
  $done=false;
  if (ini_get('allow_url_fopen') == '1') {
    if ($fp = @fopen($url, 'r')) {
      while ($line = @fread($fp, 1024)) {
        $content .= $line;
	$done=true;
      }
    }
  } 
  if (!$done) {
    // get the host name and url path
    $parsedUrl = parse_url($url);
    $host = $parsedUrl['host'];
    if (isset($parsedUrl['path'])) {
      $path = $parsedUrl['path'];
    }
    
    $timeout = 10;
    // connect to the remote server 
    $fp = @fsockopen($host, '80', $errno, $errstr, $timeout ); 
    
    if( !$fp ) { 
      // echo "Cannot retrieve $url";
    } else {
      // send the necessary headers to get the file 
      @fputs($fp, "GET $path HTTP/1.0\r\n" .
	    "Host: $host\r\n\r\n"); 
      
      // retrieve the response from the remote server 
      while ( $line = @fread( $fp, 4096 ) ) { 
        $content .= $line;
      }       
      @fclose( $fp );      
      // strip the headers
      $pos      = strpos($content, "\r\n\r\n");
      $content = substr($content, $pos + 4);
    }
  }
    
  // return the file content 
  return $content;
}

function ask2link_ad($url) {
  $h = urlencode($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
  $content=ask2link_ad_helper($url."?x-h=".$h);
  if (!preg_match('/\<Error/',$content)) {
    echo $content;
  }  
}

//echo ask2link_ad('http://s3.amazonaws.com/mf1/ad/c76e11fe0de462eb6e131243526750/ad_content');

?>


<div id="centersidebar">

	<!-- sidebar east START -->
	<div id="eastsidebar" class="sidebar">
	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('east_sidebar') ) : ?>

		<!-- categories -->
		<div class="widget widget_categories">
			<h3>Categories</h3>
			<ul>
				<?php //wp_list_cats('sort_column=name&optioncount=0&depth=1'); ?>
			</ul>
		</div>

	<?php endif; ?>
	</div>
	<!-- sidebar east END -->

	<!-- sidebar west START -->
	<div id="westsidebar" class="sidebar">
	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('west_sidebar') ) : ?>

		<!-- archives -->
		<div class="widget widget_archive">
			<h3>Archives</h3>
			<ul>
				<?php //wp_get_archives('type=monthly'); ?>
			</ul>
		</div>

	<?php endif; ?>
	</div>
	<!-- sidebar west END -->
	<div class="fixed"></div>
</div>

<!-- sidebar south START -->
<div id="southsidebar" class="sidebar">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('south_sidebar') ) : ?>

	<!-- meta -->
	<div class="widget">
		<h3>Meta</h3>
		<ul>
			<?php wp_register(); ?>
			<li><?php wp_loginout(); ?></li>
		</ul>
	</div>

<?php endif; ?>

</div>
<!-- sidebar south END -->

<!-- sidebar south START -->
<div id="southsidebarforblogup" class="sidebar">
<iframe width="150" height="350" src="http://adv.blogupp.com/codebaa5e209-7dc8-4697-8be3-2c7667ae7ef52v" scrolling="no" frameborder="0" marginwidth="0" marginheight ="0"></iframe>

<script type="text/javascript"><!--
google_ad_client = "pub-9812078506892870";
/* 页尾广告(120x240, 创建于 09-5-13) */
google_ad_slot = "6285046725";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<!-- sidebar south END -->

<div class="widget" style="float:left;"><SCRIPT type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url=www.phpcoding.cn'></SCRIPT>
</div>
<div class="widget" style="float:right;">
<a href="http://www.ask2link.com/buy-text-links?u=chcn001" title="Buy Link" target="_blank"><img src="http://www.ask2link.com/img/promotion/125x125-buy-text-links-ads.gif" alt="Text Link Ads" border="0"></a>
</div>
</div>
<!-- sidebar END -->
